﻿using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using DHQGHN.DAL.Common;
using DHQGHN.DAL.DAO.Admin;
using DHQGHN.DAL.Models.Admin;
namespace DHQGHN.DAL.BO.Admin
{
   public class EducationTrainingBO: BaseBO
   {
       #region field in database
       public const string FIELD_ID = "EDUCATION_TRAINING_ID";
       public const string FIELD_NAME = "NAME";
       public const string FIELD_CODE = "CODE";
       public const string FIELD_DESCRIPTIONS = "DESCRIPTIONS";
       public const string FIELD_DELETED = "DELETED";
       public const string FIELD_RECORD_COUNT = "RecordCount";
       #endregion
       //------------------------------------------------------
       private string _connectionString;

       public EducationTrainingBO (string connString)
       {
           connString = this._connectionString;
       }
       //------------------------------------------------------
       public EducationTrainingBO()
       {
           this._connectionString = Common.ConnectionUtil.TKTHDS_METADATA_CONNECTION_STRING;     
       }
       //------------------------------------------------------
       public EducationTrainingDAO _educationTrainingDAO;
       
       public EducationTrainingDAO CreateSQLDAO()
       {
           return new EducationTrainingDAO(_connectionString, DEFAULT_MAPPER_TYPE);
       }
       //--------------------------------------------------
       public EducationTrainingBO(string _connectionString,Type DEFAULT_MAPPER_TYPE)
        {
            this.DEFAULT_MAPPER_TYPE = DEFAULT_MAPPER_TYPE;
         }
       //----------------------------------------------
       public DataPage<EducationTrainingModel>GetDynamicListPaging(EducationTrainingModel Model, int pageIndex, int pageSize, bool compareEqual)
       {
           try
           {
               _educationTrainingDAO = CreateSQLDAO();
               Dictionary<String, String> mapDictionary = new Dictionary<string, string>()
               {
                    {EducationTrainingModel.FIELD_ID, FIELD_ID},
                    {EducationTrainingModel.FIELD_CODE, FIELD_CODE},
                    {EducationTrainingModel.FIELD_NAME, FIELD_NAME},
                    {EducationTrainingModel.FIELD_DESCRIPTIONS, FIELD_DESCRIPTIONS},
                    {EducationTrainingModel.FIELD_DELETED, FIELD_DELETED},
                    {EducationTrainingModel.FIELD_RECORD_COUNT,FIELD_RECORD_COUNT}
               };
               return _educationTrainingDAO.GetDynamicListPaging(Model, pageIndex, pageSize, mapDictionary, compareEqual);
           }
           catch (Exception) { throw; }
       }
       //----------------------------------------------
       public EducationTrainingModel GetEducationTraniningById(string Id)
       {
           try
           {
               _educationTrainingDAO = CreateSQLDAO();
               Dictionary<String, String> mapDictionary = new Dictionary<string, string>
               {
                   {EducationTrainingModel.FIELD_ID, FIELD_ID},
                   {EducationTrainingModel.FIELD_CODE, FIELD_CODE},
                   {EducationTrainingModel.FIELD_NAME, FIELD_NAME},
                   {EducationTrainingModel.FIELD_DESCRIPTIONS, FIELD_DESCRIPTIONS},
                   {EducationTrainingModel.FIELD_DELETED, FIELD_DELETED},
                   {EducationTrainingModel.FIELD_RECORD_COUNT, FIELD_RECORD_COUNT}
               };
               return _educationTrainingDAO.GetById(Id, mapDictionary);
           }
           catch (Exception) { throw; }
       }
       //--------------------------------------------------------------------
       public bool createOrUpdateEducationTraining(EducationTrainingModel model)
       {
           try
           {
               _educationTrainingDAO = CreateSQLDAO();
               return _educationTrainingDAO.createOrUpdatEducationTraining(model);
           }
           catch (Exception) { throw; }
       }
       //--------------------------------------------------------------------
       public bool deleteEducationTraining(string[]Id)
       {
           try
           {
               _educationTrainingDAO = CreateSQLDAO();
               return _educationTrainingDAO.deleteEducationTraining(Id);
           }
           catch (Exception) { throw; }
       }
   }
}
